typedef HRESULT (WINAPI *TD3DXCreateTextureFromFileInMemoryEx)(
  _In_     LPDIRECT3DDEVICE9 pDevice,
  _In_     LPCVOID pSrcData,
  _In_     UINT SrcDataSize,
  _In_     UINT Width,
  _In_     UINT Height,
  _In_     UINT MipLevels,
  _In_     DWORD Usage,
  _In_     D3DFORMAT Format,
  _In_     D3DPOOL Pool,
  _In_     DWORD Filter,
  _In_     DWORD MipFilter,
  _In_     D3DCOLOR ColorKey,
  _Inout_  D3DXIMAGE_INFO *pSrcInfo,
  _Out_    PALETTEENTRY *pPalette,
  _Out_    LPDIRECT3DTEXTURE9 *ppTexture
);

TD3DXCreateTextureFromFileInMemoryEx OldD3DXCreateTextureFromFileInMemoryEx;

DllExport HRESULT cc D3DXCreateTextureFromFileInMemoryEx(
  _In_     LPDIRECT3DDEVICE9 pDevice,
  _In_     LPCVOID pSrcData,
  _In_     UINT SrcDataSize,
  _In_     UINT Width,
  _In_     UINT Height,
  _In_     UINT MipLevels,
  _In_     DWORD Usage,
  _In_     D3DFORMAT Format,
  _In_     D3DPOOL Pool,
  _In_     DWORD Filter,
  _In_     DWORD MipFilter,
  _In_     D3DCOLOR ColorKey,
  _Inout_  D3DXIMAGE_INFO *pSrcInfo,
  _Out_    PALETTEENTRY *pPalette,
  _Out_    LPDIRECT3DTEXTURE9 *ppTexture
)
{
	//Log("CTFFInMemoryEx", 15);
	
	PDDS tmp = (PDDS)pSrcData; //pointer auf header einer DDS datei (struct selbstgebastelt)
	if ((tmp->header.dwReserved1[0]==0x47)&&(tmp->header.dwReserved1[1]==0x49)&&(tmp->header.dwReserved1[2]==0x4D)&&(tmp->header.dwReserved1[3]==0x50)&&(tmp->header.dwReserved1[4]==0x2D))
	{
		Log("MTexture Loaded", 16);
		Log((LPCSTR)(&(tmp->header.dwReserved1[0])), 16);
		Beep(1000, 100);
		Beep(3000, 100);
		Beep(1000, 100);
		//DataCopy ((void*)pSrcData, SrcDataSize);
		*aTex=(UINT)ppTexture;
		//*aTex=45;
		DWORD* size = (DWORD*)(MapViewt);
		DWORD dsize = *size;
		size++;
		void* psrc = (void*) size;
		return OldD3DXCreateTextureFromFileInMemoryEx (pDevice, psrc, dsize, 4096, 4096, MipLevels, Usage, Format, Pool, Filter, MipFilter, ColorKey, pSrcInfo, pPalette, ppTexture);  
	}
	return OldD3DXCreateTextureFromFileInMemoryEx (pDevice, pSrcData, SrcDataSize, Width, Height, MipLevels, Usage, Format, Pool, Filter, MipFilter, ColorKey, pSrcInfo, pPalette, ppTexture);
}